package facilius.controller.actionmanager;

import facilius.controller.ActionManager;
import facilius.controller.action.instituicao.InstituicaoCreateAction;
import facilius.controller.action.instituicao.InstituicaoDeleteAction;
import facilius.controller.action.instituicao.InstituicaoReadAction;
import facilius.controller.action.instituicao.InstituicaoShowFormAction;
import facilius.controller.action.instituicao.InstituicaoUpdateAction;
import org.mentawai.authorization.Permission;
import org.mentawai.core.ActionConfig;
import org.mentawai.core.ApplicationManager;
import org.mentawai.core.Forward;
import org.mentawai.core.Redirect;
import org.mentawai.filter.AuthorizationFilter;

/**
 *
 * @author Graciano
 */
public class InstituicaoActionManager implements ActionManager {

    public void loadActions(ApplicationManager appManager) {
        ActionConfig ac = null;
        ac = new ActionConfig("InstituicaoRead", InstituicaoReadAction.class);
        ac.addConsequence(appManager.SUCCESS, new Forward("jsp/instituicao/instituicaoList.page"));
        ac.addConsequence(appManager.EXCEPTION, new Forward("jsp/erro.page"));
        ac.addFilter(new AuthorizationFilter(new Permission("instituicao")));
        appManager.addActionConfig(ac);

        ac = new ActionConfig("InstituicaoShowForm", InstituicaoShowFormAction.class);
        ac.addConsequence(appManager.SUCCESS, new Forward("jsp/instituicao/instituicaoForm.page"));
        ac.addConsequence(appManager.ERROR, new Forward("jsp/erro.page"));
        ac.addFilter(new AuthorizationFilter(new Permission("instituicao")));
        appManager.addActionConfig(ac);

        ac = new ActionConfig("InstituicaoCreate", InstituicaoCreateAction.class);
        ac.addConsequence(appManager.SUCCESS, new Redirect("InstituicaoRead.mtw"));
        ac.addConsequence(appManager.ERROR, new Forward("jsp/erro.page"));
        ac.addFilter(new AuthorizationFilter(new Permission("instituicao")));
        appManager.addActionConfig(ac);

        ac = new ActionConfig("InstituicaoDelete", InstituicaoDeleteAction.class);
        ac.addConsequence(appManager.SUCCESS, new Redirect("InstituicaoRead.mtw"));
        ac.addConsequence(appManager.ERROR, new Forward("jsp/erro.page"));
        ac.addFilter(new AuthorizationFilter(new Permission("instituicao")));
        appManager.addActionConfig(ac);

        ac = new ActionConfig("InstituicaoUpdate", InstituicaoUpdateAction.class);
        ac.addConsequence(appManager.SUCCESS, new Redirect("InstituicaoRead.mtw"));
        ac.addConsequence(appManager.ERROR, new Forward("jsp/erro.page"));
        ac.addFilter(new AuthorizationFilter(new Permission("instituicao")));
        appManager.addActionConfig(ac);
    }
}
